package model;

import java.util.ArrayList;
import java.util.GregorianCalendar;

public class DailyRegular extends Prescription {

	private ArrayList<Dose> doses = new ArrayList<Dose>();
	
	public DailyRegular(GregorianCalendar startDate, GregorianCalendar endDate,
			double morningUnit, double noonUnit, double eveningUnit, double nightUnit) {
		super(startDate, endDate);
		doses.add(0, new Dose("8:00", morningUnit));
		doses.add(1, new Dose("12:00", noonUnit));
		doses.add(2, new Dose("18:00", eveningUnit));
		doses.add(3, new Dose("23:00", nightUnit));
	}

	public double getMorningUnit() {
		return doses.get(0).getCount();
	}

	public void setMorningUnit(int unit) {
		doses.get(0).setCount(unit);
	}

	public double getNoonUnit() {
		return doses.get(1).getCount();
	}

	public void setNoonUnit(int unit) {
		doses.get(1).setCount(unit);
	}
	
	public double getEveningUnit() {
		return doses.get(2).getCount();
	}

	public void setEveningUnit(int unit) {
		doses.get(2).setCount(unit);
	}

	public double getNightUnit() {
		return doses.get(3).getCount();
	}

	public void setNightUnit(int unit) {
		doses.get(3).setCount(unit);
	}
	
	@Override
	public double dayDose() {
		double count = 0;
		for (Dose dose : doses)
			count += dose.getCount();
		return count;
	}

	@Override
	public double totalDose() {
		return dayDose() * dayCount();
	}

	public Dose[] getDoses() {
		Dose[] d = new Dose[doses.size()];
		doses.toArray(d);
		return d;
	}

}
